<div class="head" >
    <div class="head-top">
        <div class="main">
            <div class="top-wel">
                @if(session_get(UserEnum::USER_INFO_SESSION_KEY))
                    <?php $cart_info = ShopService::instance()->ShopCartList();
                    $price = ShopService::instance()->ShopCartSum();
                       // dd($cart_info);
                    $cart_count = ShopService::instance()->ShopCartAllSum(); ?>
                    <!-- 登录后 -->
                    <span class="login-after">
                    您好，（{{substr(session_get(UserEnum::USER_INFO_SESSION_KEY)->mobile,0,3)}}****{{substr(session_get(UserEnum::USER_INFO_SESSION_KEY)->mobile,7)}}）
                    <a href="/logout">退出</a>
                </span>
                @else
                    <span>欢迎来钢链网</span>
                    <!-- 未登录 -->
                    <a href="/login" class="a-login">请登录</a>
                    <a href="/register" class="a-register">免费注册</a>
                @endif
            </div>
            <div class="top-nav">
                <ul>
                    <li><a href="/user_person">我的钢链网</a></li>
                    <li><a href="/user_order?status=0">我的订单</a></li>
                    <li><a href="/shop_user_news?type=all_message">消息中心<span>@if(session_get(UserEnum::USER_INFO_USER_ID)) <?php $count = ShopService::instance()->MessageCount(); if($count!=0){echo $count;}?> @endif</span></a></li>
                    <li><a href="javascript:;">在线客服</a></li>
                    <li><span><i></i>010-87152827</span></li>
                </ul>
            </div>
        </div>
    </div>
    <div class="main">
        <div class="head-nav">
            <div class="logo left">
                <a href="/"><img src="/resource/img/logo.png" alt=""></a>
            </div>
            <div class="shopping right">
                @if(session_get(UserEnum::USER_INFO_USER_ID))
                    <a href="/shop_cart_list" id="cart_num_top">
                        <i></i>购物车@if($cart_count[0]->num!=0)<span>{{$cart_count[0]->num}}</span>@else @endif
                    </a>
                @else
                    <a href="javascript:;" onclick="login()"><i></i>购物车</a>
                    <!-- 无商品 -->
                @endif
            </div>
            <div class="nav right">
                <ul>
                    @if($index_type=='index')
                        <li   class="active"><a href="/">首页</a></li>
                        <li><a href="/shopping">商城</a></li>
                        <li><a href="/new_resource">资源单</a></li>
                        <li><a href="/phone">手机客户端</a></li>
                    @elseif($index_type=='new_resource')
                        <li ><a href="/">首页</a></li>
                    <li><a href="/shopping">商城</a></li>
                    <li class="active"><a href="/new_resource">资源单</a></li>
                        <li><a href="/phone">手机客户端</a></li>
                    @elseif($index_type=='shopping')
                        <li ><a href="/">首页</a></li>
                        <li  class="active"><a href="/shopping">商城</a></li>
                        <li><a href="/new_resource">资源单</a></li>
                        <li><a href="/phone">手机客户端</a></li>
                    @elseif($index_type=='phone')
                        <li ><a href="/">首页</a></li>
                        <li><a href="/shopping">商城</a></li>
                        <li><a href="/new_resource">资源单</a></li>
                        <li   class="active"><a href="/phone">手机客户端</a></li>
                    @endif

                </ul>
            </div>
        </div>
    </div>
    <div class="clear"></div>
</div>
<!-- 右侧 -->
<div class="pos-right" >
    <div class="left pos-l-bg">
        <div class="pos-box">
            <div class="user">
                <a href="/user_person">
                    <!-- 登录 -->
                    <span>我的钢链网</span>
                </a>
            </div>
            <div class="shopping" id="shopping">
                <a href="javascript:;" id="cart_num">
                    <i></i>
                    购<br/>物<br/>车
                    @if(session_get(UserEnum::USER_INFO_SESSION_KEY))
                        @if($cart_count[0]->num!=0)<span>{{$cart_count[0]->num}}</span>@else @endif
                        @endif
                </a>
            </div>
            <ul>
                <li class="tel"><a href="javascript:;">
					<span>
						<i>客服热线</i>010-87152827<br/><br/><i>工作时间</i>周一到周五 9:00-18:00
					</span>
                    </a></li>
                <li class="service"><a href="javascript:;">
                        <span>在线客服</span>
                    </a></li>
                <li class="user"><a href="javascript:;">
                        <span>用户反馈</span>
                    </a></li>
                <li class="top" id="backTop"><a href="javascript:;">
                        <span>返回顶部</span>
                    </a></li>
            </ul>
        </div>
    </div>
    <div class="right pos-shop" id="cart_info">
        @if(session_get(UserEnum::USER_INFO_SESSION_KEY))
        <!-- 无商品 -->
            @if($cart_count[0]->num<1)
            <div class="shop-no" >
                购物车内没有商品
                <a href="/shopping">去商城选购</a>
            </div>
            @else
        <!-- 有商品 -->
        <div class="shop-in">
            <div class="in-head">
                <input type="checkbox" id="check-all" checked> 全选
                <a href="/shop_cart_list">去购物车</a>
                <i></i>
            </div>
            <div class="in-ul">
                @foreach($cart_info as $v)
                <div class="in-li">
                    <div class="bus-name">
                        <input type="checkbox" class="check-bus" checked>
                        <div class="name">{{$v->storage_name}}</div>
                    </div>
                    @foreach($v->cart_info as $vv)
                        <div class="info" stock="{{$vv->useable_stock}}">
                            <input type="checkbox" cart-id="{{$vv->cart_id}}" checked>
                            <div class="in">
                                <div class="til"><a href="javascript:;">
                                        {{$vv->brand_name}}&#160; {{$vv->product_spec}}&#160; {{$vv->m_name}}&#160; {{$vv->storage_name}}
                                    </a></div>
                                <div class="p">
                                    件重/吨：<i class="w_per_piece">{{$vv->piece_weight}} </i><span class="price">￥{{$vv->product_price}}/吨</span>
                                </div>
                                <div class="bot">
                                    <div class="info-num left">
                                        <a href="javascript:;" class="pre"></a>
                                        <input type="text" id="info-num" value="{{$vv->number}}" class="number" product_id="{{$vv->product_id}}">
                                        <a href="javascript:;" class="next"></a>
                                    </div>
                                    <a href="/head_cart_delete?cart_id={{$vv->cart_id}}" class="del">删除</a>
                                </div>
                            </div>
                        </div>
                    @endforeach

                </div>
                @endforeach
            </div>
            <div class="in-bot">
                <div class="bot-info">
                    <div class="left sta-num">共 <span>{{$cart_count[0]->num}}</span> 件</div>
                    <div class="right sta-mon">商品总计：<span>￥{{round($price[0]->price,2)}}</span></div>
                </div>
                <a href="javascript:;" id="cart-submit" class="go">去下单</a>
            </div>
        </div>
            @endif
            @else
                <div class="shop-no">
                    您还没有登陆
                    <a href="/login">去登录</a>
                </div>
            @endif
    </div>
</div>

<!-- 黑色幕 -->
<div class="popup"></div>
<!-- 登录 -->
<div class="popup-login">
    <div class="popup-bg">
        <div class="login-tit">
            用户登录<a href="/register">快速注册</a>
            <div class="login-close"></div>
        </div>
        <form action="/verify_login" class="form" onsubmit="return check_all()" method="post">
            <div class="form-group">
                <label for="">手机号</label>
                <input type="text" class="form-control" id="username" name="username" placeholder="请输入手机号">
                <i class="i i-tel"></i>
                <span id="t_tel">请输入有效的11位手机号</span>
            </div>
            <div class="form-group">
                <label for="">密码</label>
                <input type="password" class="form-control" id="pwd" name="password" placeholder="请输入密码">
                <i class="i i-pass"></i>
                <span id="t_pwd">账户不存在或密码错误</span>
            </div>
            <input type="hidden" value="login" name="index">
            <div class="form-group form-left">
                <input type="checkbox" checked> 自动登录
                <a href="/retrieve_pass">忘记密码</a>
            </div>
            <div class="form-group">
                <button type="submit" class="btn-login">登&#160&#160&#160录</button>
            </div>
        </form>
    </div>
</div>
<!-- 意见反馈 -->
<div class="popup-feedback">
    <div class="popup-bg">
        <div class="form">
            <form action="">
                <div class="form-group">
                    <textarea id="feedback_text">请留下您的意见和建议</textarea>
                </div>
                <div class="form-group">
                    <input type="text" class="form-control" placeholder="联系电话（选填）" id="phone">
                </div>
                <input type="button" class="btn-login btn-feedback" value="提交">
            </form>
        </div>
    </div>
</div>
<script>
    //正则手机号
    $('#username').blur(function(){
        var reg = /^0?1[3|4|5|8][0-9]\d{8}$/;
        var username = $(this).val();
        if (!username) {
            $('#t_tel').html('不能为空').show();
        }else{
            if (!reg.test(username)) {
                $('#t_tel').html('请输入有效的11位手机号').show();
            }else{
                $('#t_tel').hide();
            }
        }
    });

    function check_all(){
        var pwd	= $('#pwd').val();
        var username = $('#username').val();
        var reg = /^0?1[3|4|5|8][0-9]\d{8}$/;
        var status = false;
        if(pwd) {
            if (username) {
                if (!reg.test(username)) {
                    $('#t_tel').html('请输入有效的11位手机号').show();
                    return status;
                }else{
                    $('#t_tel').hide();
                    $.ajax({
                        url: "/js_verify_login",
                        type: "POST",
                        data: 'username=' + username + "&pwd=" + pwd,
                        async:false,
                        success: function (msg) {
                            if (msg == 0) {
                                $("#t_pwd").html("账户不存在或密码错误").show();
                            }else if(msg == 2){
                                $("#t_pwd").html("密码错误次数过多,请10分钟后登录").show();
                            }else if(msg == 1){
                                $("#t_pwd").hide();
                                status = true;
                            };
                        }
                    });
                }
            }else{
                $('#t_tel').html('不能为空').show();
                return status;
            }
        }else{
            $('#t_pwd').html('不能为空').show();
            return status;
        }
        return status
    }

</script>
<script>
    $(document).delegate('.btn-feedback','click',function() {	//反馈
        var opinion = $('#feedback_text').val();
        var phone   = $('#phone').val();
        if(opinion && opinion!='请留下您的意见和建议'){
            $.ajax({
                url: "/opinion",
                type: "POST",
                data: "content=" + opinion+"&mobile="+phone,
                success: function (msg) {
                    if (msg!=0) {
                        $('.popup-feedback').hide();
                        $('.popup').hide();
                        Showbo.Msg.alert('<img src="/resource/img/gl_show_succ.png" alt=""><br/>谢谢您的反馈，我们会重视每一位用户的意见！<br/><br/>');
                        $('#dvMsgBtns input.btn').css('width','140px');
                    }else if(msg==0){
                        $('.popup-feedback').hide();
                        $('.popup-login').show();
//                        Showbo.Msg.alert('请先登录！<br/><br/>');
//                        $('#dvMsgBtns input.btn').css('width','140px');
                    }
                }
            })
        }else{
            Showbo.Msg.alert('<img src="/resource/img/gl_show_err.png" alt=""><br/>请填写您的反馈建议，或意见<br/><br/>');
            $('#dvMsgBtns input.btn').css('width','140px');
        }

    })

    $('#pre').click(function() {
       var num = $("#info-num").val();
        $.ajax({
            url: "/js_verify_login",
            type: "POST",
            data: 'num=' + num,
            success: function (msg) {

            }
        });
    })

</script>